//
//  NMSGSCGroup.m
//  HNJYB
//
//  Created by Mag1cPanda on 2017/3/24.
//  Copyright © 2017年 Mag1cPanda. All rights reserved.
//

#import "NMSGSCGroup.h"

@implementation NMSGSCGroup

-(instancetype)initWithFrame:(CGRect)frame groupId:(NSString *)groupId
{
    self = [super initWithFrame:frame];
    if (self) {
        CGFloat viewWidth = ScreenWidth - 20;
        CGFloat viewHeight = 60;
        
        SGSCView *titleView = [[SGSCView alloc] initWithFrame:CGRectMake(10, 20, viewWidth, viewHeight)];
        titleView.titleLab.hidden = YES;
        titleView.field.hidden = YES;
        [self addSubview:titleView];
        
        _titleLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, viewWidth, viewHeight)];
        _titleLab.textColor = HNBlue;
        _titleLab.textAlignment = NSTextAlignmentCenter;
        [titleView addSubview:_titleLab];
        
        //----------车辆品牌-----------
        _brandView = [[SGSCView alloc] initWithFrame:CGRectMake(10, titleView.maxY + 10, viewWidth, viewHeight)];
        _brandView.titleLab.text = @"车辆品牌:";
        [self addSubview:_brandView];
        
        //----------车型--------------
        SGSCView *cxView = [[SGSCView alloc] initWithFrame:CGRectMake(10,_brandView.maxY + 10 , viewWidth, viewHeight)];
        cxView.titleLab.text = @"车型:";
        cxView.field.hidden = YES;
        [self addSubview:cxView];
        
        CGFloat btnWidth = 20;
        CGFloat btnHeight = 20;
        CGFloat btnY = 20;
        CGFloat labWidth = (self.width-100)/3-20;
        
        _radio1 = [[QRadioButton alloc] initWithDelegate:self groupId:groupId];
        _radio1.frame = CGRectMake(100, btnY, btnWidth, btnHeight);
        [cxView addSubview:_radio1];
        UILabel *lab1 = [[UILabel alloc] initWithFrame:CGRectMake(_radio1.maxX, btnY, labWidth, btnHeight)];
        lab1.text = @"2轮";
        lab1.font = HNFont(15);
        [cxView addSubview:lab1];
        
        _radio2 = [[QRadioButton alloc] initWithDelegate:self groupId:groupId];
        _radio2.frame = CGRectMake(lab1.maxX, btnY, btnWidth, btnHeight);
        [cxView addSubview:_radio2];
        UILabel *lab2 = [[UILabel alloc] initWithFrame:CGRectMake(_radio2.maxX, btnY, labWidth, btnHeight)];
        lab2.text = @"3轮";
        lab2.font = HNFont(15);
        [cxView addSubview:lab2];
        
        _radio3 = [[QRadioButton alloc] initWithDelegate:self groupId:groupId];
        _radio3.frame = CGRectMake(lab2.maxX, btnY, btnWidth, btnHeight);
        [cxView addSubview:_radio3];
        UILabel *lab3 = [[UILabel alloc] initWithFrame:CGRectMake(_radio3.maxX, btnY, labWidth, btnHeight)];
        lab3.text = @"4轮";
        lab3.font = HNFont(15);
        [cxView addSubview:lab3];
        
        //----------姓名--------------
        _nameView = [[SGSCView alloc] initWithFrame:CGRectMake(10, cxView.maxY + 10, viewWidth, viewHeight)];
        _nameView.titleLab.text = @"姓名:";
        _nameView.field.placeholder = @"请输入姓名";
        [self addSubview:_nameView];
        
        //----------联系电话--------------
        _phoneView = [[SGSCView alloc] initWithFrame:CGRectMake(10, _nameView.maxY + 10, viewWidth, viewHeight)];
        _phoneView.titleLab.text = @"联系电话:";
        _phoneView.field.placeholder = @"请输入联系电话";
        _phoneView.field.keyboardType = UIKeyboardTypePhonePad;
        [self addSubview:_phoneView];
        
        //----------身份证号--------------
        _idcardView = [[SGSCView alloc] initWithFrame:CGRectMake(10, _phoneView.maxY + 10, viewWidth, viewHeight)];
        _idcardView.titleLab.text = @"身份证号:";
        _idcardView.field.placeholder = @"请输入身份证号";
        [self addSubview:_idcardView];
        
        
    }
    return self;
}

#pragma mark - QRadioButtonDelegate
- (void)didSelectedRadioButton:(QRadioButton *)radio groupId:(NSString *)groupId
{
    if (radio == _radio1)
    {
        self.selectedIndex = @"3";
        self.carType = @"2轮";
    }
    else if (radio == _radio2)
    {
        self.selectedIndex = @"4";
        self.carType = @"3轮";
    }
    
    else {
        self.selectedIndex = @"5";
        self.carType = @"4轮";
    }
    
    NSLog(@"_selectedIndex:%@ _evaluate:%@", _selectedIndex, _carType);
}

- (void)setTitle:(NSString *)title
{
    _title = title;
    _titleLab.text = title;
}

@end
